<?php

namespace app\controllers;

use Yii;
use app\components\Oauth2Controller as Controller;


class ProductController extends Controller{

    /**
     * 产品列表
     */
    public function actionList(){

        if(!$this->server->verifyResourceRequest(\OAuth2\Request::createFromGlobals())) {

            $this->server->getResponse()->send();

            //die;
            exit(json_encode(["code"=>-1, "info"=>"failed!"], JSON_UNESCAPED_UNICODE));

        }



        $products = [
            ["id"=>1, "name"=>"iPhone 6"],
            ["id"=>2, "name"=>"iPhone 6s"],
            ["id"=>3, "name"=>"iPphone 7"],
            ["id"=>4, "name"=>"iPhone SE"],
            ["id"=>5, "name"=>"iPhone 8"],
        ];


        exit(json_encode($products, JSON_UNESCAPED_UNICODE));

    }


}
